|
|
|
|
|
|
|
Listing 20.8 shows a sample version of MyCallBackFunc, used with EnumWindows. The use for the second parameter in this case is a form name. Each time MyCallBackFunc is called, it prints some information about the window handle passed to it on the specified form. |
|
|
|
|
|
|
|
|
Listing 20.8 CALLBACK.ZIPCallback Function Demo |
|
|
|
|
|
|
|
|
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, _
lParam As Any) As Long
Function MyCallBackFunc(ByVal hwnd As Long, lParam As Form) As Long
Dim sInfo As String
'sGetWindowInfo is a wrapper
'for GetClassName and GetWindowText.
sInfo = sGetWindowInfo(hwnd)
lParam.Print "hwnd=" & hwnd & vbTab & sInfo
'Returning False causes EnumWindows to stop
'moving through the window list
MyCallBackFunc = True
End Function
Sub InitiateCallback()
'This code is called from the form's command button
Dim lRetVal As Long
Form1.Cls
lRetVal = EnumWindows(AddressOf MyCallBackFunc, Form1)
End Sub |
|
|
|
|
|
|
|
|
A sample run is shown in Figure 20.4. |
|
|
|
|
|
|
|
|
Figure 20.4 EnumWindows passes your callback funtion
the handle of each window in the task list. |
|
|
|
|
|
|
|
|
Now that you have examined callbacks, you're ready to look at a closely related concept called subclassing. To understand subclassing, you should first think of a standard Visual Basic form. You can think of the form as a special type (or class) of window. This class of |
|
|
|
|
|